package com.by.yz.activity;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.by.yz.R;
import com.by.yz.activity.base.BaseActivity;
import com.by.yz.entity.ChuFang;
import com.by.yz.loginUtil.DiagnosisRESTFul;
import com.by.yz.util.ToJSonObject;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * Created by pengpeng on 2017/4/15.
 */
public class diagnosis_result extends BaseActivity {
    TextView zhengxing,zhifa,chufang;
    String ZhengXing;
    String BingMing;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.diagnosis_result);
        setToolbarTitle("诊断结果");
        initView();
        initDatas();
    }

    void initView(){
        zhengxing = (TextView)findViewById(R.id.zhengxing);
        zhifa = (TextView)findViewById(R.id.zhifa);
        chufang = (TextView)findViewById(R.id.chufang);
    }

    void initDatas(){
        ZhengXing = getIntent().getStringExtra("ZhengXing");
        BingMing = getIntent().getStringExtra("BingMing");
        zhengxing.setText(ZhengXing);
        try {
            ZhengXing = URLEncoder.encode(ZhengXing, "Utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        DiagnosisRESTFul bmREST=new DiagnosisRESTFul();
        bmREST.getChufang(ZhengXing,BingMing,new DiagnosisRESTFul.MyPostCallBack(){
            @Override
            public void ok(JSONObject response) throws JSONException {
                ChuFang cf;
                cf= ToJSonObject.jsonToBean(response.toString(),ChuFang.class);
                zhifa.setText(cf.getZfContent());
                chufang.setText(cf.getCfContent());
            }
            @Override
            public void error(String error) {
                Log.e("hj","更新失败"+error);
            }
        });
    }
}
